export function exportPDF(dom: HTMLElement, fileName = "filename") {
  window
    .html2pdf()
    .set({ filename: fileName + ".pdf" })
    .from(dom)
    .save();
}

export function exportWord(dom: HTMLElement, fileName: string = "filename") {
  let header =
    "<html xmlns:o='urn:schemas-microsoft-com:office:office' " +
    "xmlns:w='urn:schemas-microsoft-com:office:word' " +
    "xmlns='http://www.w3.org/TR/REC-html40'>" +
    "<head><meta charset='utf-8'><title>Export HTML to Word Document with JavaScript</title></head><body>";
  let footer = "</body></html>";
  let sourceHTML = header + dom.innerHTML + footer;

  let source =
    "data:application/vnd.ms-word;charset=utf-8," +
    encodeURIComponent(sourceHTML);
  let fileDownload = document.createElement("a");
  document.body.appendChild(fileDownload);
  fileDownload.href = source;
  fileDownload.download = fileName + ".doc";
  fileDownload.click();
  document.body.removeChild(fileDownload);
}
